from PyQt5 import QtCore, QtGui, QtWidgets, QtMultimedia
from PyQt5.QtWidgets import QApplication, QCheckBox, QGridLayout, QTreeWidgetItem, QLabel, QLineEdit, QDialog, QMessageBox
from PyQt5.Qt import Qt, QThread,QMutex,pyqtSignal
from PyQt5.QtGui import QPixmap, QIcon
from PyQt5.QtCore import QTimer
from math import *
from numpy import *
import sys
from Clock import Clock
from Calculator import Calculator

class MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        # UI设置
        self.setupUi()
        QtWidgets.QApplication.setStyle('Fusion')
        self.setWindowTitle('Calculator')
        self.setWindowIcon(QIcon('./img/icon.png'))

    def setupUi(self):
        self.setObjectName("MainWindow")
        self.setFixedSize(360, 550)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        self.centralwidget = QtWidgets.QWidget(self)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
        self.centralwidget.setSizePolicy(sizePolicy)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.titleLayout = QtWidgets.QHBoxLayout()
        self.titleLayout.setContentsMargins(30, 5, 5, 0)
        self.titleLayout.setSpacing(20)
        self.titleLayout.setObjectName("titleLayout")    
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setMaximumSize(QtCore.QSize(16777215, 50))
        font = QtGui.QFont()
        font.setFamily("Cambria")
        font.setPointSize(16)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        font.setBold(False)
        self.label.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setObjectName("label")
        self.titleLayout.addWidget(self.label)
        self.titleLayout.addWidget(Clock())
        self.verticalLayout.addLayout(self.titleLayout)
        self.calculator = Calculator()
        self.verticalLayout.addWidget(self.calculator)
        self.setCentralWidget(self.centralwidget)

        self.retranslateUi(self)
        QtCore.QMetaObject.connectSlotsByName(self)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label.setText(_translate("MainWindow", "Simple Calculator"))


if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    myWin = MainWindow()
    myWin.show()
    sys.exit(app.exec_())

# 将ui文件和qrc文件转化成py文件
# pyuic5 -o ui_mainwindow.py mainwindow.ui
# pyrcc5 -o resource_rc.py resource.qrc 

# pyinstaller的使用方法
# pyinstaller -F main.py --noconsole
# pyinstaller -D main.py --noconsole

# 加在spec里面
# import sys
# sys.setrecursionlimit(5000)
